Skip to content

Update CVC5 to 1.2.X #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Mar 28, 2025
Merged

Conversation

daniel-raffler
Copy link
Contributor

Hello everyone,
this PR will update CVC5 to the latest version and rewrites the solver backend to use the new TermManager interface. It also changes the build process so that only a single library is produced and all dependencies are statically linked. In addition we added multi-arch support for linux on arm64 and windows on x64.

There were some issues in CVC5 that had to be fixed and we're still waiting on cvc5/cvc5#11730 before this can be merged.

@daniel-raffler daniel-raffler linked an issue Mar 17, 2025 that may be closed by this pull request
@daniel-raffler
Copy link
Contributor Author

@kfriedberger: Could you have a look at the last commit that adds multi-arch support? I've tried it for arm64 with qemu, but I don't have a windows machine to test the binaries. (You'll have to use the repository from the CVC5 pull request here if you want to build the binaries yourself)

@kfriedberger kfriedberger self-requested a review March 17, 2025 06:28
@daniel-raffler daniel-raffler marked this pull request as ready for review March 18, 2025 18:26
@daniel-raffler
Copy link
Contributor Author

The missing pull request for CVC5 has now been merged and we can build from main

We compile for linux on x64 and arm64 and windows on x64 only. CVC5 is also available on MacOS, but there doesn't seem to be a simple way to cross compile. The same is true for windows on arm64.
@daniel-raffler daniel-raffler force-pushed the 410-update-cvc5-to-version-120-or-newer branch from 16fdcb2 to 2abc14d Compare March 19, 2025 21:47
This reverts commit 458b8f1 and blacklists one more test. CVC5 still crashes when formulas are shared across multiple threads. Remember to reapply this commit once the issue has been solved upstream.
@daniel-raffler daniel-raffler changed the title Draft: Update CVC5 to 1.2.X Update CVC5 to 1.2.X Mar 19, 2025
Copy link
Member

@kfriedberger kfriedberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On first look, this is an impressive PR, and it looks quite good:

  • version update of CVC5 ✔️
  • arm64-support for CVC5 ✔️
  • x64-support for WIndows ❔ (does not yet work)

I will test compilation and different OS soon.

@baierd
Copy link
Contributor

baierd commented Mar 23, 2025

The proof generation/traversal API has changed compared to older versions. Do we include the new API and maybe even a native test for it?

If not, can we add that in this PR? It would be helpful for @gcarpio21 s proof interface.
(I can also do it, but probably in the later half of next week)

@kfriedberger
Copy link
Member

We compile the "full" API of CVC5, including all new features. I assume that the API changes from your comment refer to plain Java API. This should be done outside of this PR, as it might be independent of native code and low-level bindings. A separate PR would also allow to integrate this PR here soonish, and work on proofs later.

@gcarpio21
Copy link
Member

The proof generation/traversal API has changed compared to older versions. Do we include the new API and maybe even a native test for it?

If not, can we add that in this PR? It would be helpful for @gcarpio21 s proof interface. (I can also do it, but probably in the later half of next week)

For the purposes of correctly retrieving proofs from CVC5 I have written a test in the CVC5NativeAPITest class using some of the methods exposed in this version of CVC5 to handle proofs. I could add the test to this PR.

@kfriedberger
Copy link
Member

If there is just one additional test, then feel free to add it within this PR.

@kfriedberger
Copy link
Member

kfriedberger commented Mar 24, 2025

Update for the Windows build artifact:
There are remaining non-static dependencies to GCC-specific libraries. CVC5 packages them as additional libraries into the released archive:
https://github.com/cvc5/cvc5/blob/7bf5d3e457aa5c40b325b0e687de5a972b0dad4e/.github/actions/add-package/action.yml#L40-L42
We can do the same, and add those dependencies into Ivy and Maven. We would need to load those libraries before loading CVC5.

Improvement (future work, maybe within this PR):
CVC5 could be compiled "static", such that GCC-related dependencies are included. This would simplify development in JavaSMT and avoid potential conflicts with other SMT solvers.

Alternative (maybe future work, not part of this PR):
CVC5 has already a fully running build-system that publishes (nearly) static binaries for more platforms (see https://github.com/cvc5/cvc5/releases ). For other solvers, like Z3, we use the direct release instead of building our own binaries. This would only require to download several archives, and then repackage them according to our needs. This might allow us to even support MacOS on x64 and arm64 platform without any compilation overhead.

@gcarpio21
Copy link
Member

I added the test

@daniel-raffler
Copy link
Contributor Author

Update for the Windows build artifact: There are remaining non-static dependencies to GCC-specific libraries. CVC5 packages them as additional libraries into the released archive: https://github.com/cvc5/cvc5/blob/7bf5d3e457aa5c40b325b0e687de5a972b0dad4e/.github/actions/add-package/action.yml#L40-L42

Ok, that's interesting. CVC5 actually seems to copy the .dll (or .so/dylib, depending on the platform) files into the jars they publish on their website. They're then extracted from the .jar at runtime and copied to a temporary folder by cvc5.Utils.loadLibraries() where they're then loaded from. We disabled this loader mechanism and use NativeLibraries instead, but if we switch to the .jars from the CVC5 website we might not need to include any binaries at all. Then again we would have to load a different version of cvc5.jar for each platform (so that it includes the right binaries).

We can do the same, and add those dependencies into Ivy and Maven. We would need to load those libraries before loading CVC5.

Those libraries are the Mingw runtime and other solvers that are compiled with Mingw might also need them. Maybe there is a way to include them directly in JavaSMT to avoid conflicts between different versions for different solvers?

Alternatively we could also ask the CVC5 developers if they could add an option to statically link the Mingw runtime.

@daniel-raffler
Copy link
Contributor Author

Alternatively we could also ask the CVC5 developers if they could add an option to statically link the Mingw runtime.

I've now asked the CVC5 for an option to include the MinGW runtime in static builds:
cvc5/cvc5#11756

@kfriedberger:
Could you try out the patch from the discussion (here) and check that it works on Windows?

@kfriedberger
Copy link
Member

I’m traveling for work these days and haven’t even read all my emails or had time for proper testing yet (that will happen the next days) 😄 , and there’s already a proposed solution that looks valid (https://gist.github.com/daniel-raffler/6f5c34b2a57380f90f026de0f1c09262) based on my comment and a related PR (cvc5/cvc5#11757) that even further simplifies the build and packaging scripts of CVC5! You all work at an incredible pace -- truly impressive! 🚀

@daniel-raffler
Copy link
Contributor Author

I’m traveling for work these days and haven’t even read all my emails or had time for proper testing yet (that will happen the next days) 😄 , and there’s already a proposed solution that looks valid (https://gist.github.com/daniel-raffler/6f5c34b2a57380f90f026de0f1c09262) based on my comment and a related PR (cvc5/cvc5#11757) that even further simplifies the build and packaging scripts of CVC5! You all work at an incredible pace -- truly impressive! 🚀

Thanks! The PR has now been merged and is already included in the latest CVC5 dailies. I've opened a new branch here that fetches the binaries from the official CVC5 release and repackages them. This saves us quite some on the build and allows us to support macOS on both x64 and arm64 hardware.

If you'd like I could still add the commits to this PR. Or we wait and merge the other branch later?

@kfriedberger
Copy link
Member

kfriedberger commented Mar 28, 2025

Lets first finish this PR and then take a look at directly including CVC5 from the official webpage (see https://github.com/sosy-lab/java-smt/tree/cvc5-use-official-binaries).
I compiled CVC5 for Linux and Windows and published the artifact into Ivy and Maven.
I will update the tests and fix simple remaining issues here, then we merge this PR.

We can analyse this issue later.
The example projects refer to some release version of JavaSMT
and do not yet represent the current development state.
Those changes can be applied once JavaSMT had its next release.
@kfriedberger kfriedberger merged commit 3e5a1a9 into master Mar 28, 2025
0 of 3 checks passed
@kfriedberger kfriedberger deleted the 410-update-cvc5-to-version-120-or-newer branch March 28, 2025 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Update CVC5 to version 1.2.0 or newer
4 participants